using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace eCloudEdit
{
    public partial class SeriChannelForm : Form
    {
        private int workmode = 0;
        public SeriChannelForm()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;
            comboBox4.SelectedIndex = 0;
            comboBox5.SelectedIndex = 0;
        }
        public string comport
        {
            get
            {
                return this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
            }
            set
            {
                string ss = value;
                int n=Convert.ToInt32(ss.Substring(ss.Length - 1, 1));
                 this.comboBox1.SelectedIndex = n-1; 
            }
        }
        public string combaud
        {
            get
            {
                return this.comboBox2.GetItemText(this.comboBox2.SelectedItem);
            }
            set
            {
                string ss = value;
                if (ss.Equals("9600"))
                {
                    this.comboBox2.SelectedIndex = 0;
                }
                else if (ss.Equals("19200"))
                {
                    this.comboBox2.SelectedIndex = 1;
                }
                else if (ss.Equals("38400"))
                {
                    this.comboBox2.SelectedIndex = 2;
                }
                else if (ss.Equals("56000"))
                {
                    this.comboBox2.SelectedIndex = 3;
                }
                else if (ss.Equals("57600"))
                {
                    this.comboBox2.SelectedIndex = 4;
                }
                else if (ss.Equals("115200"))
                {
                    this.comboBox2.SelectedIndex = 5;
                }           
            }
        }
        public string comdatabit
        {
            get
            {
                return this.comboBox3.GetItemText(this.comboBox3.SelectedItem);
            }
            set
            {
                string ss = value;
                if (ss.Equals("8"))
                {
                    this.comboBox3.SelectedIndex = 0;
                }
                else if (ss.Equals("7"))
                {
                    this.comboBox3.SelectedIndex = 1;
                }
            }
        }
        public string comstopbit
        {
            get
            {
                return this.comboBox4.GetItemText(this.comboBox4.SelectedItem);
            }
            set
            {
                string ss = value;
                if (ss.Equals("1"))
                {
                    this.comboBox4.SelectedIndex = 0;
                }
                else if (ss.Equals("2"))
                {
                    this.comboBox4.SelectedIndex = 1;
                }
            }
        }
        public string comparity
        {
            get
            {
                return this.comboBox5.GetItemText(this.comboBox5.SelectedItem);
            }
            set
            {
                string ss = value;
                int n=Convert.ToInt32(ss.Substring(0, 1));
                this.comboBox5.SelectedIndex = n;          
            }
        }
        public string intNum
        {
            get
            {
                return this.textBox2.Text;
            }
            set
            {
                this.textBox2.Text = value;
            }
        }
        public string comtimeout
        {
            get
            {
                return this.textBox1.Text;
            }
            set
            {
                this.textBox1.Text = value;
            }
        }
        public int nWorkMode
        {
            get
            {
                if (radioButton1.Checked)
                {
                    workmode = 0;
                }
                if (radioButton2.Checked)
                {
                    workmode = 1;
                }
                return this.workmode;
            }
            set
            {
                int n = value;
                if (n==0)
                {
                    radioButton1.Checked = true;
                    radioButton2.Checked = false;
                    label9.Visible = false;
                    label10.Visible = false;
                    textBox2.Visible = false;
                }
                else if (n==1)
                {
                    radioButton1.Checked = false;
                    radioButton2.Checked = true;
                    label9.Visible = true;
                    label10.Visible = true;
                    textBox2.Visible = true;
                }
         
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void radioButton1_Click(object sender, EventArgs e)
        {
            workmode = 0;
            label9.Visible = false;
            label10.Visible = false;
            textBox2.Visible = false;
        }

        private void radioButton2_Click(object sender, EventArgs e)
        {
            workmode = 1;
            label9.Visible = true;
            label10.Visible = true;
            textBox2.Visible = true;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}